package com.gexiaobao.pigeon.ui.adapter

import android.annotation.SuppressLint
import androidx.recyclerview.widget.LinearLayoutManager
import com.chad.library.adapter.base.BaseQuickAdapter
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.DataBindBaseViewHolder
import com.gexiaobao.pigeon.app.model.bean.AppMultipleProjectList
import com.gexiaobao.pigeon.databinding.ItemAppMultipleProjectBinding

/**
 * @Author      : hxw
 * @Date        : 2024/7/22 17:27
 * @Describe    :
 */
class AdapterMultipleProject(data: ArrayList<AppMultipleProjectList>) :
    BaseQuickAdapter<AppMultipleProjectList, DataBindBaseViewHolder>(R.layout.item_app_multiple_project, data) {
    @SuppressLint("NotifyDataSetChanged")
    override fun convert(holder: DataBindBaseViewHolder, item: AppMultipleProjectList) {
        val binding = DataBindBaseViewHolder.getBinding(holder) as ItemAppMultipleProjectBinding
        binding.data = item
        binding.executePendingBindings()//防止列表抖动

        holder.setText(R.id.tvTitleRank, context.getString(R.string.Chapter) + item.projectRank + context.getString(R.string.ranking))

        holder.itemView.apply {
            binding.swipeRecyclerView.adapter = null
            val mAdapter = AdapterListMultiplePass(arrayListOf())
            mAdapter.setList(item.grades)
            binding.swipeRecyclerView.apply {
                layoutManager = LinearLayoutManager(context)
                adapter = mAdapter
                mAdapter.notifyDataSetChanged()
            }
        }
    }
}